package com.zdb.util;

import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.aigc.generation.GenerationParam;
import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.common.Message;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;

import java.util.Arrays;

public class Test {
    public static GenerationResult callAIGCGeneration() throws NoApiKeyException, InputRequiredException {
        Generation generationResult = new Generation();
        Message userMsg = Message.builder()
                .role(Role.USER.getValue())
                .content("你是谁")
                .build();
        GenerationParam build = GenerationParam.builder()
                .apiKey("sk-9a007001c70449619af5100ec1811cd0")
                .model("deepseek-r1")
                .messages(Arrays.asList(userMsg))
                .resultFormat(GenerationParam.ResultFormat.MESSAGE)
                .build();
        return generationResult.call( build);
    }

    public static void main(String[] args) {
        try {
            GenerationResult result = callAIGCGeneration();
            System.out.println("思考过程");
            System.out.println(result.getOutput().getChoices().get(0).getMessage().getReasoningContent());
            System.out.println("回复内容：");
            System.out.println(result.getOutput().getChoices().get(0).getMessage().getContent());
        } catch (NoApiKeyException | InputRequiredException e) {
            e.printStackTrace();
        }
    }
}
